package o2o.thridpost.dada.client;

import com.google.gson.annotations.SerializedName;
import lombok.*;
import o2o.config.thirdpost.dada.DadaConfig;
import o2o.thridpost.dada.config.DadaConstant;

/**
 * 达达接口调用参数
 *
 * @author sunyufan deporation@qq.com
 * @date 2021/4/30 14:49
 * @description: DadaRequestParam
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class DadaRequestParam <T> {

    @SerializedName("source_id")
    private String sourceId;

    @SerializedName("app_key")
    private String appKey;

    @SerializedName("timestamp")
    private String timestamp;

    @SerializedName("format")
    private String format;

    @SerializedName("v")
    private String version;

    @SerializedName("body")
    private T body;

    @SerializedName("signature")
    private String signature;

    public DadaRequestParam(T body, DadaConfig dadaConfig) {
        this.sourceId = dadaConfig.getSourceId();
        this.appKey = dadaConfig.getAppKey();
        this.timestamp = String.valueOf(System.currentTimeMillis());
        this.format = DadaConstant.FORMAT;
        this.version = DadaConstant.V;
        this.body = body;
    }
}
